const times = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22];

export const chooseTimes = times.map((item) => {
    return {
        label: `${item}:00-${item}:59`,
        value: String(item),
    };
});

export const formatTimes = (str = '') => {
    const arr = str.split(',');
    return arr.map((item) => `${item}:00`).join('，');
};

// 格式化日期
export const formatDate = (date) => {
    if (!date) return 'N/A'; // 如果日期为空，返回'N/A'
    const d = new Date(date); // 创建日期对象
    return isNaN(d.getTime()) ? 'Invalid Date' : d.toLocaleDateString(); // 如果日期无效，返回'Invalid Date'，否则返回本地日期字符串
};
